package com.kayt.cyberBar.cpublic.business.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.kayt.cyberBar.common.PageData;
import com.kayt.cyberBar.common.ServerResponse;
import com.kayt.cyberBar.cpublic.business.entity.po.CPublicStore;
import com.kayt.cyberBar.cpublic.business.entity.req.vo.PublicStoreReqVO;
import com.kayt.cyberBar.cpublic.business.entity.rsp.vo.PublicStoreRspVO;
import com.kayt.cyberBar.cpublic.business.server.IPublicStoreServer;
import com.kayt.cyberBar.cpublic.business.service.IPublicStoreService;

@Service("publicStoreService")
public class PublicStoreServiceImpl implements IPublicStoreService{
	@Autowired
	private IPublicStoreServer publicStoreServer;
	@Override
	public ServerResponse<PageData<PublicStoreRspVO>> getStoreList() {
		PageData<CPublicStore> storePageData = publicStoreServer.get_store_list();
		return publicStoreServer.assemble_result_list(storePageData);
	}

	@Override
	public ServerResponse<PublicStoreRspVO> addStore(PublicStoreReqVO storeReqVO) {
		CPublicStore store = publicStoreServer.add_Store(storeReqVO);
		return publicStoreServer.assemble_result(store);
	}

	@Override
	public ServerResponse<PublicStoreRspVO> updateStore(PublicStoreReqVO storeReqVO) {
		CPublicStore store = publicStoreServer.mod_store(storeReqVO);
		return publicStoreServer.assemble_result(store);
	}

	@Override
	public ServerResponse<String> deleteStore(String storeId) {
		Integer result = publicStoreServer.del_store(storeId);
		return publicStoreServer.assemble_result_string(result);
	}

	@Override
	public ServerResponse<String> updateQrImgUrl(PublicStoreReqVO storeReqVO) {
		Integer result = publicStoreServer.updateQrImgUrl(storeReqVO);
		return publicStoreServer.assemble_result_string(result);
	}

	@Override
	public ServerResponse<PublicStoreRspVO> getQrImgUrl(String storeCode) {
		CPublicStore store = publicStoreServer.findByCode(storeCode);
		return publicStoreServer.assemble_result(store);
	}
	
}
